/**
 * libnlog -- User friendly logging system with network support.
 *
 * Copyright (C) 2011
 * 	Samuel Nussbaum <samuel (dot) nussbaum (at) e-robot.ch>
 *
 * This library is free software; you can redistribute it and/or modify it under the terms of the
 * GNU Lesser General Public License as published by the Free Software Foundation; either version 3
 * of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License along with this
 * library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301 USA
 */
#ifndef __NLOG_MESSAGE_H__
#define __NLOG_MESSAGE_H__

#include "Types.hpp"
#include <typeinfo>
#include <iostream>

namespace boost {
	namespace archive {
		class text_oarchive;
		class text_iarchive;
	}
}

namespace nlog {

class Message
{
	public:
		struct Less: public ::std::binary_function<Message, Message, bool> {
			bool operator()(const Message &_a, const Message &_b) {
				return _a < _b;
			}
		};
		typedef ::boost::archive::text_iarchive IArchive;
		typedef ::boost::archive::text_oarchive OArchive;
		Message(LevelEnum _level, const String &_name);
		Message(const Message &_other);
		virtual ~Message();
		inline void setContent(const String &_content) { m_content = _content; }
		inline LevelEnum level() const { return m_level; }
		inline const Time &time() const { return *m_timestamp; }
		inline const String &content() const { return m_content; }
		inline const String &name() const { return m_name; }
		Message &operator=(const Message &_other);
		bool operator<(const Message &_other) const;
		void serialize(IArchive &, const int);
		void serialize(OArchive &, const int);

	protected:
		String m_content;
		String m_name;
		Time *m_timestamp;
		LevelEnum m_level;
};

}

#endif /* __SLOG_MESSAGE_H__ */
